import { Follow } from 'src/follow/follow.entity';
import { PhotoLike } from 'src/photo-like/photo-like.entity';
import { Photo } from 'src/photo/photo.entity';
import { Column, Entity, PrimaryGeneratedColumn, OneToMany, JoinColumn, JoinTable } from 'typeorm';
@Entity('user')
export class User {
  /**
   * 自增主键
   */
  @PrimaryGeneratedColumn({
    comment: '自增ID'
  })
  id: number;

  @Column({
    comment: '用户名'
  })
  username: string;

  @Column({
    comment: '昵称'
  })
  nickname: string;

  @Column({
    comment: '手机号'
  })
  phone: string;

  @Column({
    comment: '密码'
  })
  password: string;

  @Column({
    comment: '头像'
  })
  avatar: string;

  @Column({
    comment: '最后登录时间'
  })
  last_login_time: number;

  @Column({
    comment: '热度'
  })
  popularity_num: number;

  @Column({
    comment: '关注数'
  })
  follow_num: number;

  @Column({
    comment: '粉丝'
  })
  follower_num: number;

  @Column({
    comment: '签名'
  })
  sign: string;

  @Column({
    comment: '创建时间'
  })
  create_time: number;

  @Column({
    comment: '更新时间'
  })
  update_time: number;

  @Column({
    comment: '删除时间'
  })
  delete_time: number;

  @OneToMany((type) => Photo, (photo) => photo.user)
  @JoinColumn({ name: 'user_id' })
  photos: Photo[];

  @OneToMany((type) => PhotoLike, (photo) => photo.user)
  @JoinColumn({ name: 'user_id' })
  photo_like: PhotoLike[];

  @OneToMany((type) => Follow, (follow) => follow.fans_user)
  @JoinColumn({ name: 'follow_user_id' })
  fans: Follow[];

  @OneToMany((type) => Follow, (follow) => follow.follow_user)
  @JoinColumn({ name: 'fans_user_id' })
  follow: Follow[];
}